function [ new_individuals ] = reproduction( individuals )
% REPRODUCTION Summary of this function goes here
%   Detailed explanation goes here

global CROSS_METHOD;
global MUTATION_METHOD;
global CROSS_PROB;
global BACKPROPAGATION_PROB;
global BACKPROPAGATION_STEPS;

new_individuals = [];
j = 1;

for i = 1:2:length(individuals) - (mod(length(individuals),2))
    if rand() <= CROSS_PROB
        if CROSS_METHOD == 1
            inds = crossover_classic(individuals{i}, individuals{i+1});
        elseif CROSS_METHOD == 2
            inds = crossover_multiple(individuals{i}, individuals{i+1});
        elseif CROSS_METHOD == 3
            inds = crossover_uniform(individuals{i}, individuals{i+1});
        else
            inds = crossover_annular(individuals{i}, individuals{i+1});
        end
        new_individuals{j} = inds{1};
        new_individuals{j+1} = inds{2};
        j = j+2;
    end
end

if MUTATION_METHOD == 1
    for i = 1:length(new_individuals)
        new_individuals{i} = mutation_classic(new_individuals{i});
    end
else
    new_individuals = mutation_notuniform(new_individuals);
end

for i = 1:length(new_individuals)
    if rand() <= BACKPROPAGATION_PROB
        fprintf('Haciendo backpropagation...\n');
        for j=1:BACKPROPAGATION_STEPS
            new_individuals{i} = apply_backpropagation(new_individuals{i});
        end
    end
end

end

